package com.example.zhaojianxu.signin.psychological.result

import android.os.Bundle
import android.util.Log
import android.view.View
import com.example.zhaojianxu.signin.R
import com.example.zhaojianxu.signin.bean.BaseActivity
import com.example.zhaojianxu.signin.common.constance.ComConstance
import com.example.zhaojianxu.signin.common.http.HttpUtil
import com.example.zhaojianxu.signin.psychological.http.PsResult
import kotlinx.android.synthetic.main.activity_presult.*
import kotlinx.android.synthetic.main.common_title_bar.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class PResultActivity : BaseActivity() {

    override fun initView() {

        common_title.text = "测试结果"
        common_back.setOnClickListener {
            finish()
        }

        common_setting.visibility = View.GONE
    }

    override fun initData() {
        HttpUtil.instance.getPsycApi()?.postQueryResult(ComConstance.UID)?.enqueue(object : Callback<PsResult> {
            override fun onFailure(call: Call<PsResult>, t: Throwable) {
                Log.d("TAGGGGG", "error = ${t.message}")
            }

            override fun onResponse(call: Call<PsResult>, response: Response<PsResult>) {
                if (response.isSuccessful) {
                    activity_result_p_1.text = response.body()?.result?.title.toString()
                    activity_result_p_2.text = response.body()?.result?.content.toString()
                }
            }

        })
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_presult)
    }
}
